{extend name="public/father" /}


{block name='main'}
<div class="layui-card">
    <div class="layui-card-header">黑名单管理</div>
    <div class="layui-card-body">

        <div class="layui-btn-container">
            <button type="button" class="layui-btn layui-btn-danger deleteall"><i class="layui-icon layui-icon-delete"></i>清空黑名单</button>
            <button class="layui-btn layui-btn-primary" onclick="javascript:location.reload();"><i class="layui-icon layui-icon-ok-circle"></i> 刷新页面</button>
        </div>

        <table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>

        <script type="text/html" id="barDemo">
            <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="del" data-table="blacklists"><i class="layui-icon layui-icon-delete"></i>移除</a>
        </script>

    </div>
</div>
{/block}


{block name="js"}
<script type="text/javascript">
    layui.use(['table', 'layer', 'form'], function() {
        var $ = layui.jquery, table = layui.table, layer = layui.layer, form = layui.form;

        table.render({
            elem: '#dataTable',
            url: "{:url()}",
            title: '数据表',
            totalRow: true,
            limit: 20,
            cols: [
                [
                    {field: 'left',	title:'操作',	width:90,	align:'center',	toolbar:'#barDemo',	totalRowText:'操作'},
                    {field: 'url',	title:'来源',	minWidth:200,	totalRowText:'来源'},
                    {field: 'ip',	title:'IP地址',	width:150,	align:'center',	sort:true,	totalRowText:'IP地址'},
            {field: 'create_time',	title:'时间',	width:180,	align:'center',	totalRowText:'时间'},
                ]
            ],
            page: true
        });

    });


    $('.deleteall').click(function () {
        layer.confirm('真的要清空吗？', {
            // skin: 'layui-layer-lan',
            // closeBtn: 0,
            // anim: 6
        }, function() {
            $.get("{:url('del_all_data')}", {}, function (res) {
                if ( res.code === 1 ){
                    success(res.msg, function () {
                        window.location.reload();
                    });
                } else {
                    error(res.msg);
                }
            }, 'json');
        });

    });

</script>
{/block}
